<template>
  <uni-popup ref="popup">
    <view class="pop-content">
      <view class="con">
        <view class="text" style="margin-bottom: 30rpx">{{ text }}</view>
        <view class="remark">{{ remark }}</view>
      </view>
      <view class="btn-group row b-t">
        <view class="btn center" @click="close">
          <text>{{ cancelText }}</text>
        </view>
        <view class="btn center b-l" @click="confirm">
          <text>{{ confirmText }}</text>
        </view>
      </view>
    </view>
  </uni-popup>
</template>

<script>
import uniPopup from "../../components/uni-popup/uni-popup.vue";
/**
 * 确认对话框
 * @prop title 标题
 * @prop text 提示内容
 * @prop cancelText 取消按钮文字
 * @prop confirmText 确认按钮文字
 * @event onConfirm 确认按钮点击时触发
 */
export default {
  components: { uniPopup },
  data() {
    return {};
  },
  props: {
    title: String,
    text: String,
    remark: String,
    cancelText: {
      type: String,
      default: "取消",
    },
    confirmText: {
      type: String,
      default: "确定",
    },
  },
  methods: {
    confirm() {
      this.$emit("onConfirm");
      this.$refs.popup.close();
    },
    open() {
      this.$refs.popup.open();
    },
    close() {
      this.$emit("onClose");
      this.$refs.popup.close();
    },
  },
};
</script>

<style scoped lang='scss'>
.pop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 540rpx;
  padding-top: 36rpx;
  background-color: $uni-bg-color-grey;
  border-radius: 24rpx;
  overflow: hidden;

  .title {
    font-size: 32rpx;
    color: $uni-text-color;
    line-height: 48rpx;
    font-weight: 700;
  }
  .con {
    padding: 63rpx 40rpx;
  }
  .text {
    width: 460rpx;
    font-size: 28rpx;
    color: $uni-text-color;
    text-align: center;
  }
  .remark {
    width: 460rpx;
    font-size: 24rpx;
    color: $uni-text-color-agre;
    text-align: center;
  }
  .btn-group {
    width: 100%;
    display: flex;
    border-top: 1px solid $line-color;
  }
  .btn {
    flex: 1;
    height: 88rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: $uni-text-color-agre;

    &:last-child {
      color: $base-color;
      border-left: 1px solid $line-color;
    }
  }
}
</style>
